KISSY.use("node",function(S,Node){ 
$(".access").on("click",function(){
var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	KISSY.io({
			url: "/?a=access&m=home&c=content",
			data: {"ctp":ctp,"id":id},
			success: function(data, textStatus) {
				if(data.status==false){
					showDialog("发布内容","发布失败。。。"+data.msg,"row");
				}else{
					showDialog("发布内容","已发布至站内！","row");
				}
			},
			complete: function(data){
			},
			error: function(){
				alert('error');
			},
			dataType:"jsonp"
	});

});

$(".publish").on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	showDialog("发布内容","<img src='http://img03.taobaocdn.com/tps/i3/T1b1m3XkVpXXXXXXXX-32-32.gif' />正在发布。。。","row");
	KISSY.io({
			url: "/?a=publish&m=home&c=content",
			data: {"ctp":ctp,"id":id},
			success: function(data, textStatus) {
				closeDialog();
				if(data.status==false){
					showDialog("发布内容","发布失败。。。"+data.msg,"row");
				}else{
					KISSY.Event.detach(".bd"+id,"click");
					$(".bd"+id).removeClass("badge-warning");
					$(".bd"+id).addClass("badge-success");
					$(".bd"+id).empty();
					var s ='<span><i class="icon icon-white icon-list "></i>查看</span>';
					$(".bd"+id).on("click",function(){location.href=("/?m=front&id="+id+"&ctp="+ctp,true)});
					$(s).appendTo(".bd"+id);
					var t = '<a href="?m=front&id='+data.content_id+'&ctp='+ctp+'&a=show" target="_blank"><i class="curpoint icon icon-red icon-play pull-right"></i></a>';
					$(t).insertAfter(".icon-refresh");
					showDialog("发布内容","发布成功！"+data.msg,"row");
				}
			},
			complete: function(data){
			},
			error: function(){
				alert('error');
			},
			dataType:"jsonp"
	});

});
$(".bui-tab-item").on("click",function(){
		$(".bui-tab-item").removeClass("bui-tab-item-selected");
		$(this).addClass("bui-tab-item-selected");
		var tp = $(this).attr("data-tp");
		$(".xinde,.pics,.items").addClass("hide");
		$("."+tp).removeClass("hide");
		$(".tags").removeClass("badge-info");
		$(".tag").val('');
		var type = $(".type").val();
		if(tp=='xinde'){
			location.href=("/?a=list&m=home&c=content"+(type?"&type="+type:""));
		}else if(tp=='items'){
			location.href=("/?a=list&m=home&c=content&ctp=items"+(type?"&type="+type:""));
		}else if(tp=='pics'){
			location.href=("/?a=list&m=home&c=content&ctp=pics"+(type?"&type="+type:""));
		}
	});
$(".add").on("click",function(){
	var ctp =$(this).attr("data-ctp");
	location.href=("/?a=add&m=home&c=content&ctp="+(ctp?ctp:"content"));
});
$(".list").on("click",function(){
	var ctp =$(this).attr("data-ctp");
	location.href=("/?a=list&m=home&c=content&ctp="+(ctp?ctp:"content"));
});
// $(".badge-success").on("click",function(){
	// var ctp =$(this).attr("data-ctp");
	// var id =$(this).attr("data-id");
	// location.href=("/?m=front&id="+id+"&ctp="+ctp,true)
// });
$(".trash").on("click",function(){
	var ctp =$(this).attr("data-ctp");
	location.href=("/?a=list&m=home&c=content&ctp="+(ctp?ctp:"content")+"&type=9");
});
$('.js-reject').on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	var sid =$(this).attr("data-sid");
	var html = ("<div class=\"form-horizontal well well-small\" style=\"margin-bottom:0\">");
	html +=("	<div class=\"control-group\">");
	html +=("			<label class=\"control-label\">选择：</label>");
	html +=("				<ul class=\"controls span16\">");
	html +=("					<span class=\"label label-info curpoint  msg\">店铺不符合要求</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">商品不符要求</span>");
	html +=("					<span class=\"label label-info curpoint msg\">未悬挂指定的banner</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">折扣不达标</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">牛皮癣</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">成交不达标</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">重复报名</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">不允许的类目</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">违规处罚</span>");
	html +=("					<span class=\"label label-info curpoint  msg\">排期已满</span>");
	html +=("					<span class=\"x-icon x-icon-small x-icon-error label curpoint\"><i class=\"icon icon-white icon-repeat\"></i></span>");
	html +=("				</ul>");
	html +=("	</div>");
	html +=("	<div class=\"control-group\">");
	html +=("			<label class=\"control-label\">驳回信息：</label>");
	html +=("				<div class=\"controls\">");
	html +=("					<textarea class=\"control-text span16 js-message \" value=\"39227739834\" ></textarea>");
	html +=("				</div>");
	html +=("	</div>");
	html +=("			<div class=\"control-group centered res\"><button class=\"button js-ban\" data-sid=\""+sid+"\">确认驳回</button></div>");
	html +=("</div>");
	showDialog("发送驳回消息",html,"row");
	$(".cancel").remove();
	$(".msg").on("click",function(){
		$(".js-message").val($(".js-message").val()+" "+$(this).text());
	});
	$(".icon-repeat").on("click",function(){$(".js-message").val("")});
	$(".js-ban").on("click",function(){
		var msg = $(".js-message").val();
		if(msg==""){
			alert("请选择或输入驳回信息！");
		}else{
			KISSY.io({
					"url": "/?a=sendmsg&m=home&c=admin",
					"data": {"mixednick":sid,"message":msg,"numiid":id},
					"success": function(data, textStatus) {
						sendio(ctp,id,"/?a=remove&m=home&c=content");
					},
					"error": function(){
						alert('error');
					},
					"dataType":"jsonp"
			});
		}
	});
	
});
$('.js-unreject,.icon-ok').on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	sendio(ctp,id,"/?a=refresh&m=home&c=content");
});
$('.icon-trash,.icon-off,.js-offline').on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	showDialog("删除内容","<img src='http://img03.taobaocdn.com/tps/i3/T1b1m3XkVpXXXXXXXX-32-32.gif' />正在删除","row");
	sendio(ctp,id,"/?a=remove&m=home&c=content");
	// }
});
$('.delete').on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	sendio(ctp,id,"/?a=reject&m=home&c=content");
});
$('.icon-remove').on("click",function(){
	var ctp =$(this).attr("data-ctp");
	var id =$(this).attr("data-id");
	showDialog("删除内容","<span class='x-icon x-icon-small x-icon-error'>!</span>你确定删除？从回收站删除后无法恢复。<button class=\"button button-small button-danger confirmdelete\">删除</button>","row");
	$('.confirmdelete').on("click",function(){
		sendio(ctp,id,"/?a=delete&m=home&c=content");
	});
});
var refresh=true;
function sendio(ctp,id,url){
	KISSY.io({
			"url": url,
			"data": {"ctp":ctp,"id":id},
			"success": function(data, textStatus) {
				closeDialog();
				if(data.status==false){
					showDialog("删除内容","删除失败！！！","row");
				}else{
					$(".re"+ctp+id).addClass("hide");
					var msg = (data.type?data.type:'');
					msg += (data.info.message?data.info.message:'');
					showDialog("删除内容","已经顺利删除"+msg,"row");
				}
			},
			"complete": function(data){
			// if(url=="/?a=refresh&m=home&c=content"&&refresh){alert("已恢复，请及时审核。");refresh=false;}
			},
			"error": function(){
				alert('error');
			},
			"dataType":"jsonp"
	});
}
$(".tags").on("click",function(){
	$(".tags").removeClass("badge-info");
	$(this).addClass("badge-info");
	$(".tag").val($(this).attr("data-tagname"));
});
});